package com.localdemo.checkforloopholes.check.controller;

import com.localdemo.checkforloopholes.check.service.NvdDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 搜索数据
 *
 * @author dongsn
 * @data 2025/7/7
 */
@RestController
@RequestMapping("/fetch")
@Slf4j
public class fetchController {

    @Autowired
    private NvdDataService service;


    // http://localhost:7777/fetch/fetchCnvdData
    @GetMapping(value = "/fetchCnvdData")
    public String fetchCnvdData(HttpServletRequest req) {
        // TODO
        //  任务目标: 获取最新的漏洞信息,推送到邮件或钉钉,以防止恶意攻击
        //  1.获取安全数据 https://nvd.nist.gov/vuln/data-feeds
        //  2.解析数据
        //  3.翻译成中文
        //  4.推送给邮箱
        //  5.测试好后改为定时任务, 每天早上9点触发一次
        service.downloadAndParseNvdData();

        return "成功";
    }
}
